#!/usr/bin/env python
# encoding:utf-8
# @Time   : 2020/3/18
# @Author : 茶葫芦
# @Site   : 
# @File   : qa_server.py
import os, sys
filedir = os.path.dirname(__file__)
filedir2 = os.path.dirname(filedir)
sys.path.append(filedir)
sys.path.append(os.path.join(filedir2, 'knowledge_graph'))
import tornado.web, tornado.options, tornado.log
import tornado.ioloop
import urls
from utility.import_log import flog

floger = flog(__file__)

port = 9066
# 所有地址都可以访问,需要限定可以指定ip且baseHandler中开放白名单
address = '0.0.0.0'


class Application(tornado.web.Application):
    def __init__(self, *args, **kwargs):
        super(Application, self).__init__(*args, **kwargs)
        self.logger = floger


def main():
    tornado.options.parse_command_line()
    app = Application(urls.rute_urls, )
    app.listen(port=port, address=address)
    tornado.ioloop.IOLoop.current().start()


if __name__ == '__main__':
    floger.info(f"web server start running on port {port}...")
    main()
